package com.ruoyi.web.controller.dgw;

import java.util.List;
import java.util.Map;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.dgw.domain.TagNumberVa;
import com.ruoyi.dgw.service.ITagNumberVaService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 耳标申请Controller
 * 
 * @author ll
 * @date 2021-12-29
 */
@RestController
@RequestMapping("/dgw/va")
@Api(tags="耳标申请相关接口")
public class TagNumberVaController extends BaseController
{
    @Autowired
    private ITagNumberVaService tagNumberVaService;

    /**
     * 查询耳标申请列表
     */
    @PreAuthorize("@ss.hasPermi('dgw:va:list')")
    @GetMapping("/list")
    public TableDataInfo list(TagNumberVa tagNumberVa)
    {
        startPage();
        List<TagNumberVa> list = tagNumberVaService.selectTagNumberVaList(tagNumberVa);
        return getDataTable(list);
    }

    /**
     * 导出耳标申请列表
     */
    @PreAuthorize("@ss.hasPermi('dgw:va:export')")
    @Log(title = "耳标申请", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TagNumberVa tagNumberVa)
    {
        List<TagNumberVa> list = tagNumberVaService.selectTagNumberVaList(tagNumberVa);
        ExcelUtil<TagNumberVa> util = new ExcelUtil<TagNumberVa>(TagNumberVa.class);
        return util.exportExcel(list, "耳标申请数据");
    }

    /**
     * 获取耳标申请详细信息
     */
    @PreAuthorize("@ss.hasPermi('dgw:va:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tagNumberVaService.selectTagNumberVaById(id));
    }

    /**
     * 新增耳标申请
     */
    @ApiOperation("耳标申请")
    @PreAuthorize("@ss.hasPermi('dgw:va:add')")
    @Log(title = "耳标申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TagNumberVa tagNumberVa)
    {
        return toAjax(tagNumberVaService.insertTagNumberVa(tagNumberVa));
    }

    /**
     * 修改耳标申请
     */
    @PreAuthorize("@ss.hasPermi('dgw:va:edit')")
    @Log(title = "耳标申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TagNumberVa tagNumberVa)
    {
        return toAjax(tagNumberVaService.updateTagNumberVa(tagNumberVa));
    }

    /**
     * 删除耳标申请
     */
    @PreAuthorize("@ss.hasPermi('dgw:va:remove')")
    @Log(title = "耳标申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tagNumberVaService.deleteTagNumberVaByIds(ids));
    }

    @GetMapping("/queryVillage")
    public AjaxResult queryVillage(){
        List<Map<String, String>> list = tagNumberVaService.queryVillage();
        return AjaxResult.success(list);
    }
    @GetMapping("/queryCunVillage")
    public AjaxResult queryCunVillage(String villagesTowns){
        List<Map<String, String>> list = tagNumberVaService.queryCunVillage(villagesTowns);
        return AjaxResult.success(list);
    }
}
